how to convert nullable datetime datarow to datetime in c#

114

how to convert nullable datetime datarow to datetime in c# -

object sqlDateTime = sqldatareader[0];
DateTime? dt = (sqlDateTime == System.DBNull.Value)
    ? (DateTime?)null
    : Convert.ToDateTime(sqlDateTime);

Comments

Submit
0 Comments